import { Component } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';
import { NgIf } from '@angular/common';
@Component({
  selector: 'scan-code',
  templateUrl: 'scan-code.page.html',
  styleUrls: ['scan-code.scss'],
  standalone: true,
  imports: [IonicModule,NgIf],
})
export class ScanPage {
  scannedCode = null;
  constructor(private barcodeScanner: BarcodeScanner) {}

  startScan() {
    const options = {
      preferFrontCamera: false,
      showFlipCameraButton: true,
      showTorchButton: true,
      disableSuccessBeep: false,
      prompt: 'scan area',
    };

    this.barcodeScanner
      .scan(options)
      .then((barcodeData:any) => {
        this.scannedCode = barcodeData.text;
      })
      .catch((err:any) => {
        console.log('>>>>>>>>>>>>>>>>>>message', err);
      });
  }
}
